<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">
<script>
    (function () {
        if ('') {
            if (prompt('请输入文章密码') !== '') {
                alert('密码错误！');
                if (history.length === 1) {
                    location.replace("https://google.com"); // 这里替换成你的首页
                } else {
                    history.back();
                }
            }
        }
    })();
</script>








<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta property="og:type" content="website">
<meta property="og:title" content="苏生不惑的博客">
<meta property="og:url" content="http://yoursite.com/page/34/index.html">
<meta property="og:site_name" content="苏生不惑的博客">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="苏生不惑的博客">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/page/34/">



<meta name="referrer" content="never"> ​​​​


  <title>苏生不惑的博客</title>
  








</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">苏生不惑的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/06/10/那些你可能不知道的微博奇技淫巧/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/06/10/那些你可能不知道的微博奇技淫巧/" itemprop="url">那些你可能不知道的微博奇技淫巧</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-06-10T19:56:06+08:00">
                2019-06-10
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.4k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  5 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>微博可能是目前国内最大的公共社交平台了，今天就说说微博的一些使用技巧。</p>
<p>ps：有兴趣可以关注下我的微博@苏生不惑，地址 <a href="https://weibo.com/2717930601" target="_blank" rel="noopener">https://weibo.com/2717930601</a></p>
<p>如果你想挖我微博的黑历史，那可能要辛苦你了。毕竟我发了8万多条微博。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-0178eedbece1236a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-bc13171b78bc0d9a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="微博图床"><a href="#微博图床" class="headerlink" title="微博图床"></a>微博图床</h3><p>所谓图床，就是可以保存图片，同时允许使用图片外链，现在有很多免费的图床服务，如七牛、新浪微博。还有个人开发的<a href="http://tool.mkblog.cn/tuchuang/" target="_blank" rel="noopener">http://tool.mkblog.cn/tuchuang/</a><br><a href="https://www.superbed.cn/" target="_blank" rel="noopener">https://www.superbed.cn/</a><br>当然这些都不大稳定，比如极简图床就挂了<a href="https://jiantuku.com/" target="_blank" rel="noopener">https://jiantuku.com/</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-efae258e4a0ca678.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>微博作为上市公司，所以用微博作图床还是很稳定的，进入微博的微相册 ：<a href="http://photo.weibo.com/" target="_blank" rel="noopener">http://photo.weibo.com</a><br>上传图片会生成一个微博图片地址，比如<a href="http://wx4.sinaimg.cn/mw690/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg" target="_blank" rel="noopener">http://wx4.sinaimg.cn/mw690/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-d4a36eca2ba175dc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>新浪微博的图片会上传到ww1-ww4几台服务器上，同时会生成几张不同尺寸的图片，常用的有以下几种形式：</p>
<p><a href="http://ww1.sinaimg.cn/thumbnail/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg" target="_blank" rel="noopener">http://ww1.sinaimg.cn/thumbnail/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg</a> （缩略图）<br><a href="http://ww1.sinaimg.cn/small/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg" target="_blank" rel="noopener">http://ww1.sinaimg.cn/small/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg</a> （稍微大点的图）<br><a href="http://ww1.sinaimg.cn/bmiddle/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg" target="_blank" rel="noopener">http://ww1.sinaimg.cn/bmiddle/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg</a> （再大点的图）<br><a href="http://ww1.sinaimg.cn/large/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg（最大的）" target="_blank" rel="noopener">http://ww1.sinaimg.cn/large/c08d7e89ly1g3efjakqsaj20hs0b4dgt.jpg（最大的）</a></p>
<p>当然你直接发微博发张图片也可以的。</p>
<p>为了使用方便，有人开发了微博图床 Chrome 扩展，上传图片到微博更方便了。<br><a href="https://github.com/Semibold/Weibo-Picture-Store" target="_blank" rel="noopener">https://github.com/Semibold/Weibo-Picture-Store</a><br><a href="https://chrome.google.com/webstore/detail/pinjkilghdfhnkibhcangnpmcpdpmehk" target="_blank" rel="noopener">https://chrome.google.com/webstore/detail/pinjkilghdfhnkibhcangnpmcpdpmehk</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-baa6857a6c159dce.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="通过微博图片找到微博主页"><a href="#通过微博图片找到微博主页" class="headerlink" title="通过微博图片找到微博主页"></a>通过微博图片找到微博主页</h3><p>一般发微博都有水印的，类似这种图片右下角有@苏生不惑，这就是我的微博昵称，这个昵称是唯一的，所以通过这个昵称可以找到我的主页。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-50c72f32072815f1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>但水印可以关闭的，比如在pc版关闭。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-a6b52f2d9f25ca22.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>而且微博昵称可以更改，如果昵称改了就找不到对应的人了。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-f79f8adb1d3a0de9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>关闭水印后发的图片没有了@，上面这张图片地址是<a href="http://wx2.sinaimg.cn/large/604e48d0ly1g3b6wvy3tzj20c80ag0tq.jpg" target="_blank" rel="noopener">http://wx2.sinaimg.cn/large/604e48d0ly1g3b6wvy3tzj20c80ag0tq.jpg</a><br>使用在线工具<a href="http://www.bejson.com/othertools/pic2weibo/" target="_blank" rel="noopener">http://www.bejson.com/othertools/pic2weibo/</a><br>就可以找出微博主页，就是<a href="http://weibo.com/u/1615743184这个了。" target="_blank" rel="noopener">http://weibo.com/u/1615743184这个了。</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-766911b765abd003.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>其实微博地址中的链接后缀 604e48d0ly1g3b6wvy3tzj20c80ag0tq.jpg 前8位604e48d0ly是个16进制，Python用 int(‘604e48d0’,16)转换下到10进制就是1615743184了。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-58f1be0b85e28e4b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>如果想备份你的微博相册，可以使用脚本<a href="https://github.com/yukinotech/WeiboDL" target="_blank" rel="noopener">https://github.com/yukinotech/WeiboDL</a><br><a href="https://github.com/dataabc/weibospider" target="_blank" rel="noopener">https://github.com/dataabc/weibospider</a><br><a href="https://github.com/jdeng/weof" target="_blank" rel="noopener">https://github.com/jdeng/weof</a></p>
<p>###批量删除微博<br>不想用微博了，要删除所有微博，一条条删可是个体力活，推荐使用Chrome 扩展插件档案娘助手 ，能一键删除所有微博、删除所有转发微博、删除所有包含某些关键词的微博、删除某些日期的微博、删除所有收藏的微博、或者将所有微博转为仅自己可见、取消所有点赞微博等等。<a href="https://chrome.google.com/webstore/detail/%E6%A1%A3%E6%A1%88%E5%A8%98%E5%8A%A9%E6%89%8B/abfopppplogcojgdcfhhffngkabbhifm?utm_source=chrome-ntp-icon" target="_blank" rel="noopener">https://chrome.google.com/webstore/detail/%E6%A1%A3%E6%A1%88%E5%A8%98%E5%8A%A9%E6%89%8B/abfopppplogcojgdcfhhffngkabbhifm?utm_source=chrome-ntp-icon</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-386bc4a225341b55.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>还有专业的 <a href="http://weibo333.com/" target="_blank" rel="noopener">http://weibo333.com/</a><br><a href="https://www.weibo.com/ttarticle/p/show?id=2309404322284893507202" target="_blank" rel="noopener">https://www.weibo.com/ttarticle/p/show?id=2309404322284893507202</a><br><a href="https://www.jianshu.com/p/0e34baf98fce" target="_blank" rel="noopener">https://www.jianshu.com/p/0e34baf98fce</a><br>如果不想使用插件，也可以使用第三方脚本来删除。</p>
<p>如果只是删除无用的转发微博（原博已被删除/不可见 等）<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">javascript:<span class="keyword">void</span>((<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;<span class="keyword">var</span> e=<span class="built_in">document</span>.createElement(<span class="string">'script'</span>);<span class="keyword">var</span> ex=<span class="built_in">document</span>.createElement(<span class="string">'script'</span>);ex.setAttribute(<span class="string">'type'</span>, <span class="string">'application/javascript'</span>);ex.setAttribute(<span class="string">'src'</span>,<span class="string">'https://rawcdn.githack.com/ibesty/delete_useless_retweet_weibo/81bda850af482c844fe6e8c73f518a8e4f74fcec/bookmark.js'</span>);<span class="built_in">document</span>.body.appendChild(e);<span class="built_in">document</span>.body.appendChild(ex);&#125;)())</span><br></pre></td></tr></table></figure></p>
<p>右键点击浏览器的书签栏 -&gt; 添加书签 -&gt; 把代码粘贴到网址那一栏，书签标题可以随便写.<br>打开微博网页版 -&gt; 我的主页 -&gt; 全部微博， 然后点击刚刚新建的书签，稍等即可。</p>
<p>对应的脚本还有 <a href="https://github.com/willhunger/fuckweibo" target="_blank" rel="noopener">https://github.com/willhunger/fuckweibo</a><br><a href="https://github.com/Neulana/Xweibo" target="_blank" rel="noopener">https://github.com/Neulana/Xweibo</a></p>
<h3 id="快捷键"><a href="#快捷键" class="headerlink" title="快捷键"></a>快捷键</h3><p>输入?可以获取所有快捷键，当然这个其实并没有什么卵用，还是用鼠标方便点。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-4ea40bfd4b6f465f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-10271f43d40482ba.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="记录微博到区块链上"><a href="#记录微博到区块链上" class="headerlink" title="记录微博到区块链上"></a>记录微博到区块链上</h3><p> 发微博@BlockPin ，微博机器人 <a href="https://weibo.com/BlockPin" target="_blank" rel="noopener">@BlockPin</a>, 会自动把 @它的消息记录到区块链上。</p>
<p>大致原理是，先发到 <a href="https://demo.covenantsql.io/forum/#/" target="_blank" rel="noopener">https://demo.covenantsql.io/forum/#/</a> 然后，最多等 1min，记录会在 CovenantSQL 链上确认。刷新页面，然后点击帖子右上角的区块浏览器链接就可以找到 SQLChain 上的记录。</p>
<h3 id="正常时间序"><a href="#正常时间序" class="headerlink" title="正常时间序"></a>正常时间序</h3><p>现在的微博时间序是错乱的，所以可能会错过一些好友的最新微博动态。可以使用h5版<a href="https://m.weibo.cn/" target="_blank" rel="noopener">https://m.weibo.cn/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-39fb4123acb413ff.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>也有人开发了让PC微博首页时间线正确排布的插件。<br><a href="https://greasyfork.org/zh-CN/scripts/26247" target="_blank" rel="noopener">https://greasyfork.org/zh-CN/scripts/26247</a><br>客户端可以使用国际版微博 。</p>
<h3 id="微博热榜"><a href="#微博热榜" class="headerlink" title="微博热榜"></a>微博热榜</h3><p>想看看今天有什么热门事件，做个吃瓜群众，可以在微博搜索看到<br><a href="https://s.weibo.com/top/summary?cate=realtimehot" target="_blank" rel="noopener">https://s.weibo.com/top/summary?cate=realtimehot</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-a0366305bcceaa9f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>还有第三方做的<a href="http://www.lzuntalented.cn/tool/wb.html" target="_blank" rel="noopener">http://www.lzuntalented.cn/tool/wb.html</a> ，每隔15分钟更新。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-ca3e071a5d3f994a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>第三方做的今日热榜<a href="https://tophub.today/" target="_blank" rel="noopener">https://tophub.today/</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-35105cb7f7c01139.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-28008cf72c9970ec.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="特别关注"><a href="#特别关注" class="headerlink" title="特别关注"></a>特别关注</h3><p>想第一时间获取关注好友的动态，微博有分组功能，将对方加入特别关注组就行了，微博会及时推送给你。</p>
<p>也有第三方的APP 「即刻」创建相应的微博提醒。</p>
<h3 id="下载微博视频"><a href="#下载微博视频" class="headerlink" title="下载微博视频"></a>下载微博视频</h3><p>看到不错微博视频想下载，可以使用<a href="https://www.weibovideo.com/" target="_blank" rel="noopener">https://www.weibovideo.com/</a><br>比如下载这条视频<br><img src="https://upload-images.jianshu.io/upload_images/17817191-1ecd352316fe2429.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>输入微博地址 <a href="https://weibo.com/1875931727/HvMppjjgE就可以获取下载链接，直接下载到本地。" target="_blank" rel="noopener">https://weibo.com/1875931727/HvMppjjgE就可以获取下载链接，直接下载到本地。</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-fae777840fe55d1a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-fb37392494fe3079.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>还有个更好的下载网站<br><a href="https://weibomiaopai.com/" target="_blank" rel="noopener">https://weibomiaopai.com/</a><br> <img src="https://upload-images.jianshu.io/upload_images/17817191-5fdfb90c64bc2e68.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>好，关于微博就这些了，如果你有更好的一些实用技巧，欢迎留言交流。</p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/30/公众号精选/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/30/公众号精选/" itemprop="url">公众号精选</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-30T16:55:05+08:00">
                2019-05-30
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  399 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  1 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p><a href="https://www.ljsw.io/weixin" target="_blank" rel="noopener">逻辑思维</a></p>
<p><a href="https://www.mdnice.com/" target="_blank" rel="noopener">markdown编辑器</a></p>
<p><a href="https://github.com/hadeshe93/irm-markdowner" target="_blank" rel="noopener">微信公众号格式化工具https://md.ironmaxi.com/</a></p>
<p><a href="http://md.aclickall.com" target="_blank" rel="noopener">让公众号完美显示Latex数学公式</a></p>
<p><a href="http://yunyinggo.cn/" target="_blank" rel="noopener">自媒体运营工具</a></p>
<p><a href="https://ad.weixin.qq.com/guide/1101" target="_blank" rel="noopener">公众号广告</a></p>
<p><a href="https://data.newrank.cn/m/s.html?s=PigyPDI2KStL" target="_blank" rel="noopener">公众号内搜索</a></p>
<p><a href="http://vidlery.com/" target="_blank" rel="noopener">动画短片素材网站</a></p>
<p><a href="http://www.15um.com/tools/weixin_v.php" target="_blank" rel="noopener">公众号视频下载http://www.xmyeditor.com/tools/video.html </a> </p>
<p><a href="http://jhsjk.people.cn/" target="_blank" rel="noopener">重要讲话 </a></p>
<p><a href="https://www.banpie.info/wechat-bullet-screen/" target="_blank" rel="noopener">实现公众号文章弹幕效果</a></p>
<p><a href="https://www.banpie.info/remove-bg/" target="_blank" rel="noopener">不用PS，如何在5秒内利用AI工具帮助你自动抠图remove.bg</a></p>
<p><a href="https://github.com/BPteach/New-Media-Toolbox/blob/master/Toolkits.md" target="_blank" rel="noopener">新媒体工具箱</a></p>
<p><a href="https://pan.baidu.com/s/1JDFgosOin4onBB4LRi97Ig" target="_blank" rel="noopener">咪蒙文章大合集一共1013篇密码:hoyv</a> </p>
<p><a href="https://www.wxnmh.com/user-387-2.htm" target="_blank" rel="noopener">hugo文章</a></p>
<p><a href="https://wemp.app/accounts/70e6e2fe-a16a-4729-9fbc-6925b4bf1937?page=2" target="_blank" rel="noopener">公众号抓取文章</a></p>
<p><a href="https://wangchujiang.com/github-rank/trending.html" target="_blank" rel="noopener">github排行榜</a></p>
<p><a href="https://jinshuju.net/f/J64fx0" target="_blank" rel="noopener">房源密码: faith wenjuan.com/s/7jiyMj/</a></p>
<p><a href="https://hoxis.github.io/weixin-markdown.html" target="_blank" rel="noopener">公众号Markdown格式化网站</a></p>
<p><a href="https://mp.weixin.qq.com/s/yLIU6vTAkTsbeyyQMjM9_w" target="_blank" rel="noopener">程序员真是太太太太太有趣了</a></p>
<p><a href="http://wuzhangyang.com/2019/08/09/python-save-wechat-article/" target="_blank" rel="noopener">如何使用 Python 爬取微信公众号文章</a></p>
<p><a href="https://github.com/efonfighting/efonmark-wechat-spider" target="_blank" rel="noopener">公众号文章下载项目</a></p>
<p><a href="https://www.lizenghai.com/archives/18708.html" target="_blank" rel="noopener">Python爬取微信公众号文章并保存为PDF文件</a></p>
<p><a href="https://mp.weixin.qq.com/s/DuX8oFLJhZZlb2nkplWnxQ" target="_blank" rel="noopener">所有工具神器</a></p>
<p>历史“黑科技” <a href="https://mp.weixin.qq.com/s/EtoNa6o0GDuOz8o1mOlK7w" target="_blank" rel="noopener">https://mp.weixin.qq.com/s/EtoNa6o0GDuOz8o1mOlK7w</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MjM5OTIyMzg0NA==&amp;mid=2650200775&amp;idx=1&amp;sn=b9db46b93345683ebe15d74f32af7607&amp;chksm=bf3ccd8c884b449ae8dc215daefd9520a3e3064d2c3b112509813721b3fbf98ccf26fa03bb1f&amp;mpshare=1&amp;scene=1&amp;srcid=&amp;sharer_sharetime=1568214475808&amp;sharer_shareid=e54269eefbb93de964a99e285a0c29d8&amp;key=443d50b7f259efeef17552c315596ea86037133d2ffe1bdc706255b8fb374ed9bf9db9d9e9e31977afaba1c4242b2af19fde56a01c895c1cf4d7cfe93f0f81dd8823c776aeac3a625f4b11e69c58199c&amp;ascene=1&amp;uin=MTU0MTQzNjQwMw%3D%3D&amp;devicetype=Windows+7&amp;version=6207012a&amp;lang=zh_CN&amp;pass_ticket=pSfQk53AGDx9C7YbSRB12ShooOwwdaz44lYvNmltvGT9xxL3SrEH3a14FDMCSx63" target="_blank" rel="noopener">按键精灵 如何优雅的爬取公众号信息</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzIxMzgyOTg1MQ==&amp;mid=2247486945&amp;idx=1&amp;sn=a29a8cbd18fd7c30556c0722b92fb546&amp;chksm=97b19c55a0c61543dd831f3a52e00827c610e019c89af701862a084bfa78adfb6a3e2c6fa8db&amp;mpshare=1&amp;scene=1&amp;srcid=&amp;sharer_sharetime=1568612571811&amp;sharer_shareid=cdfd3a6280a94380e3f42a45ffc7db82&amp;key=2a4ff15fdd846346e99fd2088ee0b4dd32baf8bad69b91bf4863b9dfa539d4c48cb8aea0638b00e9e3b489087e204e7c9c0bcf9ba8d30edbcfc800fd557d2e6ba709e7cfad4043aaba4dabed66a55456&amp;ascene=1&amp;uin=NjQ3OTQwMTAy&amp;devicetype=Windows+7&amp;version=6207012a&amp;lang=zh_CN&amp;pass_ticket=7S4UktXMWCEuzbfvgIm1m22QbsPD6P5BOqyMuP60qCopDF9PqQJGVE9No8Oz1%2Fhm" target="_blank" rel="noopener">零成本、零流量，我是如何空手反套白狼？</a></p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzA5NzgzODI5NA==&amp;mid=2454037244&amp;idx=1&amp;sn=c6869aab754355af93e6958c0c4810c4&amp;key=6f23511bf9e1c01f74c9bfc67feea7e10277cb5303167cfdb57988f570cd832cc15f773f0a91d0054cdaac24569682d7937ed09c1941b468405c2f90ecd4247dc63a84f78c23ca153ec46199d6f82722&amp;ascene=1&amp;uin=NjQ3OTQwMTAy&amp;devicetype=Windows+7&amp;version=6207012a&amp;lang=zh_CN&amp;pass_ticket=7S4UktXMWCEuzbfvgIm1m22QbsPD6P5BOqyMuP60qCopDF9PqQJGVE9No8Oz1%2Fhm" target="_blank" rel="noopener">靠谱的Pycharm汉化安装+破解详细教程</a></p>
<p>Pycharm汉化+永久激活链接：<a href="https://pan.baidu.com/s/1x9oGzsEM0YpHzp6QhUeP-A" target="_blank" rel="noopener">https://pan.baidu.com/s/1x9oGzsEM0YpHzp6QhUeP-A</a>  提取码：jket </p>
<p>可以一键自动排版至微信公众号、知乎专栏、微博头条、简书、头条号、企鹅号。<a href="https://www.mkeditor.com/" target="_blank" rel="noopener">https://www.mkeditor.com/</a></p>
<p><a href="https://pan.baidu.com/s/19QBUmlimRhImC6Ugj40UHw#list/path=%2F&amp;parentPath=%2F" target="_blank" rel="noopener">https://pan.baidu.com/s/19QBUmlimRhImC6Ugj40UHw#list/path=%2F&amp;parentPath=%2F</a>  ，关于文案写作和公众号运营  提取码: tb2x ​​​​ </p>
<p><a href="https://mp.weixin.qq.com/s?__biz=MzAxOTQxNTUxNQ==&amp;mid=2650088307&amp;idx=1&amp;sn=aaf3a0db6d916b41e14875d38b93600c&amp;chksm=83c6ebc7b4b162d1ca1cb278c6cf6bbcd55a8ed10405475d120d508623b644b7a14d3871e960&amp;mpshare=1&amp;scene=1&amp;srcid=1009ARoyueVzra4VPXw6nSHA&amp;sharer_sharetime=1570620500222&amp;sharer_shareid=86890a3795c1962bad592e76258b2237&amp;key=6f23511bf9e1c01f2ecb2341d45a3d419fc674dc58ada957341dfe2da1a31ce601e64d27d5952efa5765f7a176f2fd6afa190349f0d0c2af082e594e7a3497e79dd6e2349665a901c15ea41787e2fe1e&amp;ascene=1&amp;uin=NjQ3OTQwMTAy&amp;devicetype=Windows+7&amp;version=62070141&amp;lang=zh_CN&amp;pass_ticket=i6Tfy6w1ppbyEflvnKljqHeBgFmo0k6CVnrWuKaUWmpJyTcOd9C6zf6OfPrP7MRd" target="_blank" rel="noopener"> 1.3万字长文拆解：“群勾搭小程序”实现从0到1的3大增长方案</a>  </p>
<p><a href="http://yyeer.com/%E8%AF%BB%E4%B9%A6/2017/12/18/%E4%BB%8E%E9%9B%B6%E5%BC%80%E5%A7%8B%E5%AD%A6%E5%BE%AE%E4%BF%A1%E8%BF%90%E8%90%A5-%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/" target="_blank" rel="noopener">《从零开始学微信运营》读书笔记</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/win8-安装-Python-命令行报错/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/win8-安装-Python-命令行报错/" itemprop="url">win8 安装 Python 命令行报错</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:54:37+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  194 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  1 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>重装了系统，用的是win8 64位。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-e9ba9c8eeb674fb6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>进入<a href="https://www.python.org/downloads/windows/" target="_blank" rel="noopener">官网</a>,下载最新版<a href="https://www.python.org/ftp/python/3.7.3/python-3.7.3-amd64.exe" target="_blank" rel="noopener">3.7.3</a><br>安装很顺利，但是进入命令行输入Python却一直提示 没有这个文件api-ms-win-crt-runtimel1-1-0.dll<br><img src="https://upload-images.jianshu.io/upload_images/17817191-733690defe7d582b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>于是开始搜索 win8 api-ms-win-crt-runtimel1-1-0.dll ，找到 <a href="https://blog.csdn.net/csdnwr/article/details/80980335" target="_blank" rel="noopener">这篇文章</a><br>先安装 <a href="https://www.microsoft.com/zh-cn/download/details.aspx?id=48145" target="_blank" rel="noopener">VC redit.exe</a>也安装成功了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8bd469c91adff7bc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>再<a href="https://www.microsoft.com/zh-cn/download/details.aspx?id=49093" target="_blank" rel="noopener">安装KB2999226补丁程序</a> 一直提示<br><img src="https://upload-images.jianshu.io/upload_images/17817191-b1a8c8d540d7155b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>真的很无奈，看<a href="https://www.cnblogs.com/zhongtang/p/7448823.html" target="_blank" rel="noopener">这篇文章</a>也是无解，都崩溃了。在官网搜索到<a href="https://answers.microsoft.com/zh-hans/windows/forum/windows8_1-update/windows%E6%9B%B4%E6%96%B0kb2999226%E8%A1%A5/ea2b65f7-efd6-490b-bce7-8f5521e6b5e8" target="_blank" rel="noopener">这个问题</a><br>依然无解<br><img src="https://upload-images.jianshu.io/upload_images/17817191-e8b2ef7209fb4ae4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>最后实在无奈了，在sf搜索到 <a href="https://segmentfault.com/a/1190000014021333" target="_blank" rel="noopener">Windows64+Python3+selenium3自动化环境的搭建(1)</a></p>
<p>终于在这个问题 <a href="https://segmentfault.com/q/1010000005021904" target="_blank" rel="noopener">python3.5启动报错api-ms-win-crt-runtime丢失</a>找到答案</p>
<p>下载了<a href="https://www.python.org/ftp/python/3.4.4/python-3.4.4.amd64.msi" target="_blank" rel="noopener">3.4.4版本</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-b584f0821f8bb87c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>终于成功了！<br><img src="https://upload-images.jianshu.io/upload_images/17817191-45bd5a3218f168d9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/Python-词云分析周杰伦《晴天》/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/Python-词云分析周杰伦《晴天》/" itemprop="url">Python 词云分析周杰伦《晴天》</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:53:48+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.2k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>词云可以通过网站 <a href="https://wordart.com/" target="_blank" rel="noopener">https://wordart.com/</a> 纽扣词云<a href="http://cloud.niucodata.com/" target="_blank" rel="noopener">http://cloud.niucodata.com/</a> 来制作，然而 Python 可以通过代码来实现，下面开始吧。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-de54e88a7d3a239c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br></pre></td><td class="code"><pre><span class="line">pip install wordcloud ,jieba</span><br><span class="line"><span class="keyword">import</span> jieba,wordcloud</span><br><span class="line">#选取周杰伦的《晴天》歌词</span><br><span class="line">mytext = <span class="string">""</span><span class="string">"</span></span><br><span class="line"><span class="string">故事的小黄花</span></span><br><span class="line"><span class="string">从出生那年就飘着</span></span><br><span class="line"><span class="string">童年的荡秋千</span></span><br><span class="line"><span class="string">随记忆一直晃到现在</span></span><br><span class="line"><span class="string">ㄖㄨㄟ ㄙㄡ ㄙㄡ ㄒ一 ㄉㄡ ㄒ一ㄌㄚ</span></span><br><span class="line"><span class="string">Re So So Si Do Si La</span></span><br><span class="line"><span class="string">ㄙㄡ ㄌㄚ ㄒ一 ㄒ一 ㄒ一 ㄒ一 ㄌㄚ ㄒ一 ㄌㄚ ㄙㄡ</span></span><br><span class="line"><span class="string">So La Si Si Si Si La Si La So</span></span><br><span class="line"><span class="string">吹着前奏望着天空</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">我想起花瓣试着掉落</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">为你翘课的那一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">花落的那一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">教室的那一间</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">我怎么看不见</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">消失的下雨天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">我好想再淋一遍</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">没想到失去的勇气我还留着</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">好想再问一遍</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">你会等待还是离开</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">刮风这天我试过握着你手</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但偏偏雨渐渐大到我看你不见</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">还要多久我才能在你身边</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">等到放晴的那天也许我会比较好一点</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">从前从前有个人爱你很久</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但偏偏风渐渐把距离吹得好远</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">好不容易又能再多爱一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但故事的最后你好像还是说了拜拜</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">为你翘课的那一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">花落的那一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">教室的那一间</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">我怎么看不见</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">消失的下雨天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">我好想再淋一遍</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">没想到失去的勇气我还留着</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">好想再问一遍</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">你会等待还是离开</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">刮风这天我试过握着你手</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但偏偏雨渐渐大到我看你不见</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">还要多久我才能在你身边</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">等到放晴的那天也许我会比较好一点</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">从前从前有个人爱你很久</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">偏偏风渐渐把距离吹得好远</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">好不容易又能再多爱一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但故事的最后你好像还是说了拜拜</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">刮风这天我试过握着你手</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但偏偏雨渐渐大到我看你不见</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">还要多久我才能够在你身边</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">等到放晴那天也许我会比较好一点</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">从前从前有个人爱你很久</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但偏偏雨渐渐把距离吹得好远</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">好不容易又能再多爱一天</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">但故事的最后你好像还是说了拜</span></span><br><span class="line"><span class="string">"</span><span class="string">""</span></span><br><span class="line">mytext = <span class="string">" "</span>.join(jieba.cut(mytext))</span><br><span class="line"><span class="keyword">from</span> collections <span class="keyword">import</span> Counter</span><br><span class="line">c = Counter(text_jieba)</span><br><span class="line">c = c.most_common(<span class="number">10</span>)</span><br><span class="line"></span><br><span class="line">[(<span class="string">' '</span>, <span class="number">522</span>), (<span class="string">'\n'</span>, <span class="number">98</span>), (<span class="string">'你'</span>, <span class="number">19</span>), (<span class="string">'的'</span>, <span class="number">17</span>), (<span class="string">'我'</span>, <span class="number">13</span>), (<span class="string">'好'</span>, <span class="number">10</span>), (<span class="string">'但'</span>,</span><br><span class="line"><span class="number">8</span>), (<span class="string">'着'</span>, <span class="number">8</span>), (<span class="string">'再'</span>, <span class="number">7</span>), (<span class="string">'ㄒ'</span>, <span class="number">7</span>)]</span><br><span class="line"><span class="keyword">from</span> wordcloud <span class="keyword">import</span> WordCloud</span><br><span class="line">wordcloud = WordCloud(font_path=<span class="string">"c:\windows\fonts\simhei.ttf"</span>).generate(mytext)</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line">plt.imshow(wordcloud, interpolation=<span class="string">'bilinear'</span>)</span><br><span class="line">plt.axis(<span class="string">"off"</span>)</span><br><span class="line">plt.show()</span><br><span class="line"># 保存图片</span><br><span class="line">wordcloud.to_file(<span class="string">'test.jpg'</span>)</span><br></pre></td></tr></table></figure>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-a8419c1874dbf31e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>下面进行歌词的情感分析<br><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> snownlp <span class="keyword">import</span> SnowNLP</span><br><span class="line">s = SnowNLP(mytext)</span><br><span class="line"><span class="keyword">for</span> sentence <span class="keyword">in</span> s.sentences:</span><br><span class="line">    print(sentence)</span><br><span class="line"></span><br><span class="line">故事 的 小黄花</span><br><span class="line">从 出生 那年 就 飘 着</span><br><span class="line">童年 的 荡秋千</span><br><span class="line">随 记忆 一直 晃到 现在</span><br><span class="line">ㄖ ㄨ ㄟ   ㄙ ㄡ   ㄙ ㄡ   ㄒ 一   ㄉ ㄡ   ㄒ 一 ㄌ ㄚ</span><br><span class="line">Re   So   So   Si   Do   Si   La</span><br><span class="line">ㄙ ㄡ   ㄌ ㄚ   ㄒ 一   ㄒ 一   ㄒ 一   ㄒ 一   ㄌ ㄚ   ㄒ 一   ㄌ ㄚ   ㄙ ㄡ</span><br><span class="line">So   La   Si   Si   Si   Si   La   Si   La   So</span><br><span class="line">吹 着 前奏 望 着 天空</span><br><span class="line">我 想起 花瓣 试着 掉落</span><br><span class="line">为 你 翘 课 的 那 一天</span><br><span class="line">花落 的 那 一天</span><br><span class="line">教室 的 那 一间</span><br><span class="line">我 怎么 看不见</span><br><span class="line">消失 的 下雨天</span><br><span class="line">我 好 想 再 淋 一遍</span><br><span class="line">没想到 失去 的 勇气 我 还 留 着</span><br><span class="line">好 想 再 问 一遍</span><br><span class="line">你 会 等待 还是 离开</span><br><span class="line">刮风 这天 我试 过握 着 你 手</span><br><span class="line">但 偏偏 雨 渐渐 大到 我 看 你 不见</span><br><span class="line">还要 多久 我 才能 在 你 身边</span><br><span class="line">等到 放晴 的 那天 也许 我会 比较 好 一点</span><br><span class="line">从前 从前 有 个人 爱 你 很 久</span><br><span class="line">但 偏偏 风 渐渐 把 距离 吹得 好 远</span><br><span class="line">好不容易 又 能 再 多 爱 一天</span><br><span class="line">但 故事 的 最后 你 好像 还是 说 了 拜拜</span><br><span class="line">为 你 翘 课 的 那 一天</span><br><span class="line">花落 的 那 一天</span><br><span class="line">教室 的 那 一间</span><br><span class="line">我 怎么 看不见</span><br><span class="line">消失 的 下雨天</span><br><span class="line">我 好 想 再 淋 一遍</span><br><span class="line">没想到 失去 的 勇气 我 还 留 着</span><br><span class="line">好 想 再 问 一遍</span><br><span class="line">你 会 等待 还是 离开</span><br><span class="line">刮风 这天 我试 过握 着 你 手</span><br><span class="line">但 偏偏 雨 渐渐 大到 我 看 你 不见</span><br><span class="line">还要 多久 我 才能 在 你 身边</span><br><span class="line">等到 放晴 的 那天 也许 我会 比较 好 一点</span><br><span class="line">从前 从前 有 个人 爱 你 很 久</span><br><span class="line">偏偏 风 渐渐 把 距离 吹得 好 远</span><br><span class="line">好不容易 又 能 再 多 爱 一天</span><br><span class="line">但 故事 的 最后 你 好像 还是 说 了 拜拜</span><br><span class="line">刮风 这天 我试 过握 着 你 手</span><br><span class="line">但 偏偏 雨 渐渐 大到 我 看 你 不见</span><br><span class="line">还要 多久 我 才 能够 在 你 身边</span><br><span class="line">等到 放晴 那天 也许 我会 比较 好 一点</span><br><span class="line">从前 从前 有 个人 爱 你 很 久</span><br><span class="line">但 偏偏 雨 渐渐 把 距离 吹得 好 远</span><br><span class="line">好不容易 又 能 再 多 爱 一天</span><br><span class="line">但 故事 的 最后 你 好像 还是 说 了 拜</span><br><span class="line"></span><br><span class="line">#第一句的情感分析结果</span><br><span class="line">s1 = SnowNLP(s.sentences[<span class="number">0</span>])</span><br><span class="line">s1.sentiments</span><br><span class="line">0.8849970682062196#正向情感</span><br><span class="line">#分析 好不容易 又 能 再 多 爱 一天</span><br><span class="line">s1 = SnowNLP(s.sentences[<span class="number">-2</span>])</span><br><span class="line">s1.sentiments</span><br><span class="line">0.21646625648493734#这个情绪就比较负面了</span><br></pre></td></tr></table></figure></p>
<p>公众号：苏生不惑</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-07e7d6bb987909f8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/Pyhon-爬虫框架-looter/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/Pyhon-爬虫框架-looter/" itemprop="url">Pyhon 爬虫框架 looter</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:52:54+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  873 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>知名的pyspider，scrapy就不说了，今天说说这个 looter</p>
<h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><p>先安装好python3，需要3.6以上，然后执行 pip install looter<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">λ looter -h</span><br><span class="line">Looter, a python package designed <span class="keyword">for</span> web crawler lovers :)</span><br><span class="line">Author: alphardex  QQ:<span class="number">2582347430</span></span><br><span class="line">If any suggestion, please contact me.</span><br><span class="line">Thank you <span class="keyword">for</span> cooperation!</span><br><span class="line"></span><br><span class="line">Usage:</span><br><span class="line">  looter genspider &lt;name&gt; [--<span class="keyword">async</span>]</span><br><span class="line">  looter shell [&lt;url&gt;]</span><br><span class="line">  looter (-h | --help | --version)</span><br><span class="line"></span><br><span class="line">Options:</span><br><span class="line">  -h --help        Show this screen.</span><br><span class="line">  --version        Show version.</span><br><span class="line">  --async          Use async instead of concurrent.</span><br></pre></td></tr></table></figure></p>
<h2 id="图片爬虫"><a href="#图片爬虫" class="headerlink" title="图片爬虫"></a>图片爬虫</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">λ looter shell https:<span class="comment">//konachan.com/post</span></span><br><span class="line"></span><br><span class="line">Available objects:</span><br><span class="line">    url           The url <span class="keyword">of</span> the site you crawled.</span><br><span class="line">    res           The response <span class="keyword">of</span> the site.</span><br><span class="line">    tree          The element source tree to be parsed.</span><br><span class="line"></span><br><span class="line">Available functions:</span><br><span class="line">    fetch         Send HTTP request to the site and parse it <span class="keyword">as</span> a tree. [has <span class="keyword">async</span> version]</span><br><span class="line">    view          View the page <span class="keyword">in</span> your browser. (test rendering)</span><br><span class="line">    links         Get the links <span class="keyword">of</span> the page.</span><br><span class="line">    save          Save what you crawled <span class="keyword">as</span> a file. (json or csv)</span><br><span class="line"></span><br><span class="line">Examples:</span><br><span class="line">    Get all the &lt;li&gt; elements <span class="keyword">of</span> a &lt;ul&gt; table:</span><br><span class="line">        &gt;&gt;&gt; items = tree.css(<span class="string">'ul li'</span>)</span><br><span class="line"></span><br><span class="line">    Get the links <span class="keyword">with</span> a regex pattern:</span><br><span class="line">        &gt;&gt;&gt; items = links(res, pattern=r<span class="string">'.*/(jpeg|image)/.*'</span>)</span><br><span class="line"></span><br><span class="line">For more info, plz refer to documentation:</span><br><span class="line">    [looter]: https:<span class="comment">//looter.readthedocs.io/en/latest/</span></span><br><span class="line"> imgs = tree.css(<span class="string">'a.directlink::attr(href)'</span>).extract()</span><br><span class="line">&gt;&gt;&gt; imgs[<span class="number">1</span>:<span class="number">10</span>]</span><br><span class="line">[<span class="string">'https://konachan.com/jpeg/c67d38b73df6e32199127998fc0f3338/Konachan.com%20-%20283270%20ass%20bed%20blush%20breasts%20clover_%28sakura_gamer%29%20game_cg%20nipples%20pussy_juice%20red_hair%20sakura_gamer%20wanaca%20winged_cloud.jpg'</span>, <span class="string">'https://konachan.com/image/a0952daaf9aa94cd676901203680fec4/Konachan.com%20-%20283269%20aliasing%20anus%20azur_lane%20blush%20breasts%20cum%20gray_hair%20group%20long_hair%20nipples%20nude%20penis%20pussy%20rak_%28kuraga%29%20red_eyes%20twintails%20uncensored.jpg'</span>, <span class="string">'https://konachan.com/image/e8ea71c93a895d87338ebf17e3aef5b3/Konachan.com%20-%20283268%20aliasing%20anthropomorphism%20azur_lane%20blush%20breasts%20gray_hair%20group%20long_hair%20nipples%20nude%20penis%20pussy%20rak_%28kuraga%29%20red_eyes%20sex%20twintails%20uncensored.jpg'</span>, <span class="string">'https://konachan.com/image/8ffb6f968ffe372ea90a339934a9749d/Konachan.com%20-%20283267%20bed%20blush%20brown_eyes%20brown_hair%20condom%20inanaki_shiki%20long_hair%20navel%20no_bra%20open_shirt%20original%20panties%20tie%20underwear.jpg'</span>, <span class="string">'https://konachan.com/jpeg/0d1de5c59eaf6fc717d63912e076de1d/Konachan.com%20-%20283266%20ass%20bed%20black_hair%20brown_eyes%20long_hair%20matsuzaki_miyuki%20original%20ponytail%20shorts.jpg'</span>, <span class="string">'https://konachan.com/jpeg/7b34654c53e43879f20a8fd642c32acc/Konachan.com%20-%20283264%20aqua_eyes%20bed%20blonde_hair%20blush%20breasts%20censored%20dark_skin%20navel%20nipples%20no_bra%20original%20penis%20pubic_hair%20pussy%20sex%20shirt_lift%20spread_legs%20tan_lines.jpg'</span>, <span class="string">'https://konachan.com/image/00a0eb43c07e9361679b5389e284ef7f/Konachan.com%20-%20283263%20ass%20ball%20brown_eyes%20cameltoe%20dress%20erect_nipples%20gray_hair%20kokkoro%20loli%20panties%20pizanuko%20pointed_ears%20princess_connect%21%20underwear%20upskirt%20wristwear.jpg'</span>, <span class="string">'https://konachan.com/jpeg/889214118e9a891c63f0cb759d809775/Konachan.com%20-%20283262%202girls%20animal%20bow%20brown_eyes%20brown_hair%20clouds%20dress%20feathers%20flowers%20gloves%20green_eyes%20headdress%20idolmaster%20loli%20ribbons%20rose%20short_hair%20sky%20tiara.jpg'</span>, <span class="string">'https://konachan.com/image/c7a3f7f9d6a2c1dc17c4c13733f72aed/Konachan.com%20-%20283261%20bikini_top%20black_hair%20blue_eyes%20boots%20chain%20flat_chest%20gloves%20hoodie%20inosia%20kuroi_mato%20long_hair%20magic%20navel%20scar%20shorts%20signed%20sword%20twintails%20weapon.jpg'</span>]</span><br><span class="line">Path(<span class="string">'konachan.txt'</span>).write_text(<span class="string">'\n'</span>.join(imgs))</span><br><span class="line">wget -i konachan.txt</span><br></pre></td></tr></table></figure>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-a0229a3f0c166a90.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h2 id="抓取-v2"><a href="#抓取-v2" class="headerlink" title="抓取 v2"></a>抓取 v2</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">import</span> looter <span class="keyword">as</span> lt</span><br><span class="line"><span class="keyword">from</span> pprint <span class="keyword">import</span> pprint</span><br><span class="line"><span class="keyword">from</span> concurrent <span class="keyword">import</span> futures</span><br><span class="line"></span><br><span class="line">domain = <span class="string">'https://www.v2ex.com'</span></span><br><span class="line">total = []</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def crawl(url):</span><br><span class="line">    tree = lt.fetch(url)</span><br><span class="line">    items = tree.css(<span class="string">'#TopicsNode .cell'</span>)</span><br><span class="line">    <span class="keyword">for</span> item <span class="keyword">in</span> items:</span><br><span class="line">        data = &#123;&#125;</span><br><span class="line">        data[<span class="string">'title'</span>] = item.css(<span class="string">'span.item_title a::text'</span>).extract_first()</span><br><span class="line">        data[<span class="string">'author'</span>] = item.css(<span class="string">'span.small.fade strong a::text'</span>).extract_first()</span><br><span class="line">        data[<span class="string">'source'</span>] = f<span class="string">"&#123;domain&#125;&#123;item.css('span.item_title a::attr(href)').extract_first()&#125;"</span></span><br><span class="line">        reply = item.css(<span class="string">'a.count_livid::text'</span>).extract_first()</span><br><span class="line">        data[<span class="string">'reply'</span>] = int(reply) <span class="keyword">if</span> reply <span class="keyword">else</span> <span class="number">0</span></span><br><span class="line">        pprint(data)</span><br><span class="line">        total.append(data)</span><br><span class="line">    time.sleep(<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    tasklist = [f<span class="string">'&#123;domain&#125;/go/python?p=&#123;n&#125;'</span> <span class="keyword">for</span> n <span class="keyword">in</span> range(<span class="number">1</span>, <span class="number">10</span>)]</span><br><span class="line">    [crawl(task) <span class="keyword">for</span> task <span class="keyword">in</span> tasklist]</span><br><span class="line">    lt.save(total, name=<span class="string">'v2ex.csv'</span>, sort_by=<span class="string">'reply'</span>, order=<span class="string">'desc'</span>)</span><br></pre></td></tr></table></figure>
<p>抓取10页python主题的数据，按照回复数倒序排列<br><img src="https://upload-images.jianshu.io/upload_images/17817191-c05d10edeffae35e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><img src="https://upload-images.jianshu.io/upload_images/17817191-77c6224b3f5761c4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">,author,reply,source,title</span><br><span class="line"><span class="number">0</span>,chinesehuazhou,<span class="number">127</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/562327#reply127,10 行 Python 代码，批量压缩图片 500 张，简直太强大了（内有公号宣传，不喜勿进）</span></span><br><span class="line"><span class="number">1</span>,chinesehuazhou,<span class="number">103</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/557286#reply103,len(x) 击败 x.len()，从内置函数看 Python 的设计思想（内有公号宣传，不喜勿进）</span></span><br><span class="line"><span class="number">2</span>,nfroot,<span class="number">73</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/555249#reply73,面对 Python 的强大和难用性表示深深的迷茫，莫非打开方式不对？</span></span><br><span class="line"><span class="number">3</span>,css3,<span class="number">58</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/554724#reply58,你们用什么工具来管理 Python 的库啊？</span></span><br><span class="line"><span class="number">4</span>,Northxw,<span class="number">54</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/558529#reply54,花式反爬之某众点评网</span></span><br><span class="line"><span class="number">5</span>,akmonde,<span class="number">48</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/559926#reply48,Python 项目移植到其他机器，要求全 Linux 系统适配</span></span><br><span class="line"><span class="number">6</span>,kayseen,<span class="number">47</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/562683#reply47,这道 Python 题目有大神会做吗?</span></span><br><span class="line"><span class="number">7</span>,hellomacos,<span class="number">41</span>,<span class="attr">https</span>:<span class="comment">//www.v2ex.com/t/562413#reply41,老生常谈的问题：如何学好 Python</span></span><br></pre></td></tr></table></figure></p>
<p>公众号：苏生不惑<br> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/5-分钟使用-hugo-搭建一个自己的博客/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/5-分钟使用-hugo-搭建一个自己的博客/" itemprop="url">5 分钟使用 hugo 搭建一个自己的博客</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:52:14+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  436 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  1 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Hugo是由Go语言实现的静态网站生成器。相比hexo更简单、易用、高效、易扩展、快速部署。</p>
<h2 id="安装Hugo"><a href="#安装Hugo" class="headerlink" title="安装Hugo"></a>安装Hugo</h2><h3 id="下载二进制"><a href="#下载二进制" class="headerlink" title="下载二进制"></a>下载二进制</h3><p>进入<a href="https://github.com/spf13/hugo/releases" target="_blank" rel="noopener">github下载地址</a>，选择对应系统的二进制文件，比如我的电脑windows 64位就下载 <a href="https://github.com/gohugoio/hugo/releases/download/v0.55.5/hugo_0.55.5_Windows-64bit.zip" target="_blank" rel="noopener">hugo_0.55.5_Windows-64bit.zip
</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-1f741ffef692cbf6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>解压出来就是一个EXE文件，加入到环境变量即可</p>
<h3 id="源码安装"><a href="#源码安装" class="headerlink" title="源码安装"></a>源码安装</h3><p>先安装go，git，设置GOPATH<br>命令行执行 go get -u -v github.com/spf13/hugo，成功后会生成二进制文件</p>
<h2 id="生成站点"><a href="#生成站点" class="headerlink" title="生成站点"></a>生成站点</h2><p>打开命令行，我使用的是cmder，当然自带的cmd也行。<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkdir blog</span><br><span class="line">cd blog</span><br><span class="line">hugo <span class="keyword">new</span> site .</span><br></pre></td></tr></table></figure></p>
<p>目录结构为<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8b8cafcfc1076ac4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h2 id="编写正文"><a href="#编写正文" class="headerlink" title="编写正文"></a>编写正文</h2><p>使用md语法编辑文件<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hugo <span class="keyword">new</span> hello.md</span><br><span class="line">vi hello.md</span><br></pre></td></tr></table></figure></p>
<h2 id="下载主题"><a href="#下载主题" class="headerlink" title="下载主题"></a>下载主题</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd themes</span><br><span class="line">git clone https:<span class="comment">//github.com/spf13/hyde.git</span></span><br></pre></td></tr></table></figure>
<h2 id="运行Hugo"><a href="#运行Hugo" class="headerlink" title="运行Hugo"></a>运行Hugo</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">hugo server --theme=hyde --buildDrafts</span><br><span class="line">Building sites …</span><br><span class="line">                   | EN</span><br><span class="line">+------------------+----+</span><br><span class="line">  Pages            | <span class="number">11</span></span><br><span class="line">  Paginator pages  |  <span class="number">0</span></span><br><span class="line">  Non-page files   |  <span class="number">0</span></span><br><span class="line">  Static files     |  <span class="number">6</span></span><br><span class="line">  Processed images |  <span class="number">0</span></span><br><span class="line">  Aliases          |  <span class="number">0</span></span><br><span class="line">  Sitemaps         |  <span class="number">1</span></span><br><span class="line">  Cleaned          |  <span class="number">0</span></span><br><span class="line"></span><br><span class="line">Total <span class="keyword">in</span> <span class="number">335</span> ms</span><br><span class="line">Watching <span class="keyword">for</span> changes <span class="keyword">in</span> d:\blog\&#123;content,data,layouts,<span class="keyword">static</span>,themes&#125;</span><br><span class="line">Watching <span class="keyword">for</span> config changes <span class="keyword">in</span> d:\blog\config.toml</span><br><span class="line">Environment: <span class="string">"development"</span></span><br><span class="line">Serving pages <span class="keyword">from</span> memory</span><br><span class="line">Running <span class="keyword">in</span> Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender</span><br><span class="line">Web Server is available at http:<span class="comment">//localhost:1313/ (bind address 127.0.0.1)</span></span><br><span class="line">Press Ctrl+C to stop</span><br></pre></td></tr></table></figure>
<p>浏览器里打开： <a href="http://localhost:1313" target="_blank" rel="noopener">http://localhost:1313</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-5bda2e6978db9dfb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h2 id="部署到github"><a href="#部署到github" class="headerlink" title="部署到github"></a>部署到github</h2><p>在github建立一个repo，比如username.github.io，注意username为自己的用户名，不能为其他的。<br><code>hugo --theme=hyde --baseUrl=&quot;http://xxx.github.io/&quot;</code><br>这样静态页面都会生成到 public 目录，将pubilc目录里所有文件 push 到刚创建的Repo的 master 分支就可以了。<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"> cd public</span><br><span class="line"> git init</span><br><span class="line">git remote add origin https:<span class="comment">//github.com/xxx/xxx.github.io.git</span></span><br><span class="line"> git add .</span><br><span class="line"> git commit -m <span class="string">"hugo"</span></span><br><span class="line"> git push -u origin master</span><br></pre></td></tr></table></figure></p>
<p>打开浏览器访问：<a href="http://xxx.github.io/" target="_blank" rel="noopener">http://xxx.github.io/</a></p>
<p>好了，你的博客搭建成功了，开始你的博客之旅吧。<br>公众号：苏生不惑<br> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/命令行工具之-speedtest-测试网速/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/命令行工具之-speedtest-测试网速/" itemprop="url">命令行工具之 speedtest 测试网速</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:50:48+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  873 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  4 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>介绍一个专业的网络测速工具speedtest <a href="https://www.speedtest.net/" target="_blank" rel="noopener">https://www.speedtest.net/</a>，国内有对应站点 <a href="http://www.speedtest.cn/" target="_blank" rel="noopener">http://www.speedtest.cn/</a></p>
<h3 id="下载和上传"><a href="#下载和上传" class="headerlink" title="下载和上传"></a>下载和上传</h3><p>网络数据传输分为发送数据和接收数据两部分。上传就是向外部发送数据，下载为从外部接收数据。它们都受网络带宽和设备性能制约。 在日常网络传输中大致1Mbps=125KB/s（1:8换算）。1M宽带即指1Mbps=1000Kbps=1000/8KBps=125KBps； 因此1M的带宽下载的速度一般不会超过125KB每秒。例如上行的网络带宽为100Mbps,那么最大上传速度就是12500KB/s，也就是12.5MB/s。</p>
<p>用户申请的宽带业务速率指技术上所能达到的最大理论速率值，用户上网时还受到用户电脑软硬件的配置、所浏览网站的位置、对端网站带宽等情况的影响，故用户上网时的速率通常低于理论速率值。 理论上：2M（即2Mb/s）宽带理论速率是：256KB/s（即256*8=2048Kb/s），实际速率大约为103–200kB/s；4M（即4Mb/s）的宽带理论速率是：512KB/s，实际速率大约为200—440kB/s。</p>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><p>pip install speedtest-cli<br>或者下载这个文件 <a href="https://raw.github.com/sivel/speedtest-cli/master/speedtest.py" target="_blank" rel="noopener">https://raw.github.com/sivel/speedtest-cli/master/speedtest.py</a><br> 修改文件名为 speed-cli即可。<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line">λ speed-cli -h</span><br><span class="line">usage: speed-cli.py [-h] [--no-download] [--no-upload] [--single] [--bytes]</span><br><span class="line">                    [--share] [--simple] [--csv]</span><br><span class="line">                    [--csv-delimiter CSV_DELIMITER] [--csv-header] [--json]</span><br><span class="line">                    [--list] [--server SERVER] [--exclude EXCLUDE]</span><br><span class="line">                    [--mini MINI] [--source SOURCE] [--timeout TIMEOUT]</span><br><span class="line">                    [--secure] [--no-pre-allocate] [--version]</span><br><span class="line"></span><br><span class="line">Command line interface <span class="keyword">for</span> testing internet bandwidth using speedtest.net.</span><br><span class="line">--------------------------------------------------------------------------</span><br><span class="line">https:<span class="comment">//github.com/sivel/speedtest-cli</span></span><br><span class="line"></span><br><span class="line">optional <span class="built_in">arguments</span>:</span><br><span class="line">  -h, --help            show <span class="keyword">this</span> help message and exit</span><br><span class="line">  --no-download         Do not perform download test</span><br><span class="line">  --no-upload           Do not perform upload test</span><br><span class="line">  --single              Only use a single connection instead <span class="keyword">of</span> multiple. This</span><br><span class="line">                        simulates a typical file transfer.</span><br><span class="line">  --bytes               Display values <span class="keyword">in</span> bytes instead <span class="keyword">of</span> bits. Does not</span><br><span class="line">                        affect the image generated by --share, nor output <span class="keyword">from</span></span><br><span class="line">                        --json or --csv</span><br><span class="line">  --share               Generate and provide a URL to the speedtest.net share</span><br><span class="line">                        results image, not displayed <span class="keyword">with</span> --csv</span><br><span class="line">  --simple              Suppress verbose output, only show basic information</span><br><span class="line">  --csv                 Suppress verbose output, only show basic information</span><br><span class="line">                        <span class="keyword">in</span> CSV format. Speeds listed <span class="keyword">in</span> bit/s and not affected</span><br><span class="line">                        by --bytes</span><br><span class="line">  --csv-delimiter CSV_DELIMITER</span><br><span class="line">                        Single character delimiter to use <span class="keyword">in</span> CSV output.</span><br><span class="line">                        Default <span class="string">","</span></span><br><span class="line">  --csv-header          Print CSV headers</span><br><span class="line">  --json                Suppress verbose output, only show basic information</span><br><span class="line">                        <span class="keyword">in</span> <span class="built_in">JSON</span> format. Speeds listed <span class="keyword">in</span> bit/s and not</span><br><span class="line">                        affected by --bytes</span><br><span class="line">  --list                Display a list <span class="keyword">of</span> speedtest.net servers sorted by</span><br><span class="line">                        distance</span><br><span class="line">  --server SERVER       Specify a server ID to test against. Can be supplied</span><br><span class="line">                        multiple times</span><br><span class="line">  --exclude EXCLUDE     Exclude a server <span class="keyword">from</span> selection. Can be supplied</span><br><span class="line">                        multiple times</span><br><span class="line">  --mini MINI           URL <span class="keyword">of</span> the Speedtest Mini server</span><br><span class="line">  --source SOURCE       Source IP address to bind to</span><br><span class="line">  --timeout TIMEOUT     HTTP timeout <span class="keyword">in</span> seconds. Default <span class="number">10</span></span><br><span class="line">  --secure              Use HTTPS instead <span class="keyword">of</span> HTTP when communicating <span class="keyword">with</span></span><br><span class="line">                        speedtest.net operated servers</span><br><span class="line">  --no-pre-allocate     Do not pre allocate upload data. Pre allocation is</span><br><span class="line">                        enabled by <span class="keyword">default</span> to improve upload performance. To</span><br><span class="line">                        support systems <span class="keyword">with</span> insufficient memory, use <span class="keyword">this</span></span><br><span class="line">                        option to avoid a MemoryError</span><br><span class="line">  --version             Show the version number and exit</span><br></pre></td></tr></table></figure></p>
<h3 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">λ speed-cli --share</span><br><span class="line">Retrieving speedtest.net configuration...</span><br><span class="line">Testing <span class="keyword">from</span> China Network Information Center (<span class="number">218.98</span><span class="number">.33</span><span class="number">.181</span>)...</span><br><span class="line">Retrieving speedtest.net server list...</span><br><span class="line">Selecting best server based on ping...</span><br><span class="line">Hosted by China Mobile Group Beijing Co.Ltd (Beijing) [<span class="number">1.67</span> km]: <span class="number">8.13</span> ms</span><br><span class="line">Testing download speed................................................................................</span><br><span class="line">Download: <span class="number">18.58</span> Mbit/s</span><br><span class="line">Testing upload speed......................................................................................................</span><br><span class="line">Upload: <span class="number">5.79</span> Mbit/s</span><br><span class="line">Share results: http:<span class="comment">//www.speedtest.net/result/8272084022.png</span></span><br></pre></td></tr></table></figure>
<p>我电脑下载速度 18.58 Mbit/s，在网站 <a href="https://cn.office-converter.com/Bandwidth-3" target="_blank" rel="noopener">https://cn.office-converter.com/Bandwidth-3</a> 换算下就是2.32MB/s<br><img src="https://upload-images.jianshu.io/upload_images/17817191-9abb33b20ea85a6f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>生成的图片地址<a href="http://www.speedtest.net/result/8272084022.png" target="_blank" rel="noopener">http://www.speedtest.net/result/8272084022.png</a> 可以分享给他人。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-8a2038cb374c86e3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="装逼测速"><a href="#装逼测速" class="headerlink" title="装逼测速"></a>装逼测速</h3><p>看别人分享的网速比自己快那么多，想盘他们怎么办？用<a href="https://github.com/kasuganosoras/speedtest-fake" target="_blank" rel="noopener">speedtest-fake</a><br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">λ php speedtest.php</span><br><span class="line">Retrieving speedtest.net configuration...</span><br><span class="line">Testing <span class="keyword">from</span> China Telecom Guangdong (<span class="number">183.15</span>.xxx.xx)...</span><br><span class="line">Retrieving speedtest.net server list...</span><br><span class="line">Selecting best server based on ping...</span><br><span class="line">Hosted by W Professional Services Limited (New Territories) [<span class="number">18.14</span> km]: <span class="number">43.12</span> ms</span><br><span class="line">Testing download speed................................................................................</span><br><span class="line">Download: <span class="number">14770.61</span> Mbit/s</span><br><span class="line">Testing upload speed................................................................................................</span><br><span class="line">Upload: <span class="number">10512.14</span> Mbit/s</span><br></pre></td></tr></table></figure></p>
<p>14770.61 Mbit/s 够装逼用了，当然这个只能截图了。</p>
<h3 id="公众号：苏生不惑"><a href="#公众号：苏生不惑" class="headerlink" title="公众号：苏生不惑"></a>公众号：苏生不惑</h3><p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/听说你想-520-表白/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/听说你想-520-表白/" itemprop="url">听说你想 520 表白</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:49:58+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  431 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  1 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>又到520，一个狂虐单身狗的日子，看看知乎的热门话题：<br><img src="https://upload-images.jianshu.io/upload_images/17817191-02aede8544cba52f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>这里给大家提供几个虐狗的新姿势。</p>
<h3 id="69"><a href="#69" class="headerlink" title="69"></a>69</h3><p>表白从 69 开始，给对方发个网页 <a href="http://118.24.158.116:8888/loveyou.html" target="_blank" rel="noopener">http://118.24.158.116:8888/loveyou.html</a><br>用浏览器打开，按Ctrl+f 输入9，效果就出来了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-6e504ecf85427319.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="表白网页生成器"><a href="#表白网页生成器" class="headerlink" title="表白网页生成器"></a>表白网页生成器</h3><p>打开网站 <a href="https://res.luyi.org/love/" target="_blank" rel="noopener">https://res.luyi.org/love/</a> ，填入要表白的内容：<br><img src="https://upload-images.jianshu.io/upload_images/17817191-c58e05af7dcdc17f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"><br>生成好的网页 <a href="https://res.luyi.org/love/love.php?me=%E6%9D%A8%E8%BF%87&amp;you=%E5%B0%8F%E9%BE%99%E5%A5%B3&amp;yi=%E8%BF%87%E5%84%BF%E7%88%B1%E4%BD%A0%E4%B8%80%E7%94%9F%E4%B8%80%E4%B8%96&amp;wu=%E5%B0%B1%E6%98%AF%E7%88%B1%E4%BD%A0&amp;year=2019&amp;yue=5&amp;ri=20&amp;submit=" target="_blank" rel="noopener">https://res.luyi.org/love/love.php?me=%E6%9D%A8%E8%BF%87&amp;you=%E5%B0%8F%E9%BE%99%E5%A5%B3&amp;yi=%E8%BF%87%E5%84%BF%E7%88%B1%E4%BD%A0%E4%B8%80%E7%94%9F%E4%B8%80%E4%B8%96&amp;wu=%E5%B0%B1%E6%98%AF%E7%88%B1%E4%BD%A0&amp;year=2019&amp;yue=5&amp;ri=20&amp;submit=</a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-9365a5bdea8e7f6d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h3 id="百度传情"><a href="#百度传情" class="headerlink" title="百度传情"></a>百度传情</h3><p>其实百度很早就有个传情功能，直接百度输入 表白 即可。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-9e955671afcf70bf.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>输入好对方名字和留言，点击生成爱情密码，可以自定义4-8位密码（不能和别人的重合），也可以随机生成。比如我生成的这个密码数字 20196699，然后让对方百度输入 解蜜20196699 就可以看到你对她的表白了，而且这个网页百度会一直保存着。<a href="https://www.baidu.com/s?wd=%E8%A7%A3%E8%9C%9C20196699&amp;rsv_spt=1&amp;rsv_iqid=0xcae3b6f70000da9b&amp;issp=1&amp;f=8&amp;rsv_bp=1&amp;rsv_idx=2&amp;ie=utf-8&amp;rqlang=cn&amp;tn=baiduhome_pg&amp;rsv_enter=0&amp;oq=%25E8%25A7%25A3%25E8%259C%259C24667500&amp;inputT=78350&amp;rsv_t=e116MvmallMxcerBcArNhKG5nWP9%2Frtb8bi42ZMA4nB8T9%2BHXGkc%2FkkS5F3U%2FpQ0F7Sf&amp;rsv_pq=bf13f0e60003d3e4&amp;rsv_sug3=44&amp;rsv_sug2=0&amp;rsv_sug4=78350" target="_blank" rel="noopener">https://www.baidu.com/s?wd=%E8%A7%A3%E8%9C%9C20196699&amp;rsv_spt=1&amp;rsv_iqid=0xcae3b6f70000da9b&amp;issp=1&amp;f=8&amp;rsv_bp=1&amp;rsv_idx=2&amp;ie=utf-8&amp;rqlang=cn&amp;tn=baiduhome_pg&amp;rsv_enter=0&amp;oq=%25E8%25A7%25A3%25E8%259C%259C24667500&amp;inputT=78350&amp;rsv_t=e116MvmallMxcerBcArNhKG5nWP9%2Frtb8bi42ZMA4nB8T9%2BHXGkc%2FkkS5F3U%2FpQ0F7Sf&amp;rsv_pq=bf13f0e60003d3e4&amp;rsv_sug3=44&amp;rsv_sug2=0&amp;rsv_sug4=78350</a></p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-e21864066c081c5c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>当然如果觉得以上都太虚的话，没事，微信都为你准备好了，每到这一天微信红包提高到 520，记得备好红包！当然首先你得有个女朋友。。。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/微信好友头像拼图/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/微信好友头像拼图/" itemprop="url">微信好友头像拼图</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:49:22+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  602 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  2 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>微信机器人相信很多人在群里见过，大部分是基于itchat开发的，今天就用基于 itchat 的wxpy 将你的微信好友头像拼接成一张图片。</p>
<h2 id="安装-wxpy"><a href="#安装-wxpy" class="headerlink" title="安装 wxpy"></a>安装 wxpy</h2><p>直接pip install wxpy 即可。<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">λ wxpy -h</span><br><span class="line">usage: wxpy [-h] [-c] [-q width] [-l level] [-s shell] [-v] [bot [bot ...]]</span><br><span class="line"></span><br><span class="line">Run a wxpy-ready python <span class="built_in">console</span>.</span><br><span class="line"></span><br><span class="line">positional <span class="built_in">arguments</span>:</span><br><span class="line">  bot                   One or more variable name(s) <span class="keyword">for</span> bot(s) to init</span><br><span class="line">                        (<span class="keyword">default</span>: None).</span><br><span class="line"></span><br><span class="line">optional <span class="built_in">arguments</span>:</span><br><span class="line">  -h, --help            show <span class="keyword">this</span> help message and exit</span><br><span class="line">  -c, --cache           Cache session(s) <span class="keyword">for</span> a short time, or load session(s)</span><br><span class="line">                        <span class="keyword">from</span> cache (<span class="keyword">default</span>: disabled).</span><br><span class="line">  -q width, --console_qr width</span><br><span class="line">                        The width <span class="keyword">for</span> console_qr (<span class="keyword">default</span>: None).</span><br><span class="line">  -l level, --logging_level level</span><br><span class="line">                        Logging level (<span class="keyword">default</span>: INFO).</span><br><span class="line">  -s shell, --shell shell</span><br><span class="line">                        Specify which shell to use: ipython, bpython, or</span><br><span class="line">                        python (<span class="keyword">default</span>: the first available).</span><br><span class="line">  -v, --version         Show version and exit.</span><br></pre></td></tr></table></figure></p>
<h2 id="源码"><a href="#源码" class="headerlink" title="源码"></a>源码</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br></pre></td><td class="code"><pre><span class="line"># -*- coding: utf-8 -*-</span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> wxpy <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">import</span> math</span><br><span class="line"><span class="keyword">from</span> PIL <span class="keyword">import</span> Image</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line">print(<span class="string">'双击exe执行，用微信扫描弹出的二维码，确认后等待一段时间，会在本地生成合成文件mywechat.png，有问题@苏生不惑'</span>)</span><br><span class="line"># </span><br><span class="line">def creat_filepath():</span><br><span class="line">    avatar_dir = os.getcwd() + <span class="string">"\\wechat_pic\\"</span></span><br><span class="line">    <span class="keyword">if</span> not os.path.exists(avatar_dir):</span><br><span class="line">        os.mkdir(avatar_dir)</span><br><span class="line">    <span class="keyword">return</span> avatar_dir</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def save_avatar(avatar_dir):</span><br><span class="line">    # </span><br><span class="line">    bot = Bot()</span><br><span class="line">    friends = bot.friends(update=True)</span><br><span class="line">    print(friends.stats_text())</span><br><span class="line"></span><br><span class="line">    # 下载</span><br><span class="line">    num = <span class="number">0</span></span><br><span class="line">    <span class="keyword">for</span> friend <span class="keyword">in</span> friends:</span><br><span class="line">        friend.get_avatar(avatar_dir + <span class="string">'\\'</span> + str(num) + <span class="string">".jpg"</span>)</span><br><span class="line">        print(<span class="string">'好友昵称:%s'</span> % friend.nick_name)</span><br><span class="line">        num = num + <span class="number">1</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">def joint_avatar(path):</span><br><span class="line">    # </span><br><span class="line">    length = len(os.listdir(path))</span><br><span class="line">    # </span><br><span class="line">    image_size = <span class="number">2560</span></span><br><span class="line">    # </span><br><span class="line">    each_size = math.ceil(<span class="number">2560</span> / math.floor(math.sqrt(length)))</span><br><span class="line">    # </span><br><span class="line">    x_lines = math.ceil(math.sqrt(length))</span><br><span class="line">    y_lines = math.ceil(math.sqrt(length))</span><br><span class="line">    image = Image.new(<span class="string">'RGB'</span>, (each_size * x_lines, each_size * y_lines))</span><br><span class="line">    x = <span class="number">0</span></span><br><span class="line">    y = <span class="number">0</span></span><br><span class="line">    <span class="keyword">for</span> (root, dirs, files) <span class="keyword">in</span> os.walk(path):</span><br><span class="line">        <span class="keyword">for</span> pic_name <span class="keyword">in</span> files:</span><br><span class="line">            </span><br><span class="line">                <span class="keyword">try</span>:</span><br><span class="line">                    <span class="keyword">with</span> Image.open(path + pic_name) <span class="keyword">as</span> img:</span><br><span class="line">                        img = img.resize((each_size, each_size))</span><br><span class="line">                        image.paste(img, (x * each_size, y * each_size))</span><br><span class="line">                        x += <span class="number">1</span></span><br><span class="line">                        <span class="keyword">if</span> x == x_lines:</span><br><span class="line">                            x = <span class="number">0</span></span><br><span class="line">                            y += <span class="number">1</span></span><br><span class="line">                except IOError:</span><br><span class="line">                    print(<span class="string">"头像读取失败"</span>)</span><br><span class="line"></span><br><span class="line">    img = image.save(os.getcwd() + <span class="string">"/mywechat.png"</span>)</span><br><span class="line">    print(<span class="string">'微信好友头像拼接完成!'</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    avatar_dir = creat_filepath()</span><br><span class="line">    save_avatar(avatar_dir)</span><br><span class="line">    joint_avatar(avatar_dir)</span><br></pre></td></tr></table></figure>
<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><p>python wechat.py<br>将会弹出二维码，打开微信扫描登录，如果你的好友过千的话需要等待一段时间。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-6ed226d86c470093.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">Login successfully <span class="keyword">as</span> 风吹麦浪</span><br><span class="line">好友昵称:风吹麦浪</span><br></pre></td></tr></table></figure>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-828f5e86e8f5effc.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<h2 id="效果"><a href="#效果" class="headerlink" title="效果"></a>效果</h2><p>最后生成了所有好友的微信头像拼图，我的好友才100多人，所以生成的头像还能看清，如果有几千好友的话头像会很小，需要放大才能看到。</p>
<p><img src="https://upload-images.jianshu.io/upload_images/17817191-428cad2031a94b8f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="拼图"></p>
<p>所有好友的微信头像都下载到本地了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-3cc49a8411fb16fb.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="所有好友头像"></p>
<p>赶紧发条朋友圈去装逼吧，哈哈。</p>
<p>如果你不会代码的话，我生成了一个EXE文件，只需要在电脑双击执行这个EXE就能自动拼图了。<br><img src="https://upload-images.jianshu.io/upload_images/17817191-f959a73d636c554a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image.png"></p>
<p>关注本公众号，回复 微信拼图 获取EXE下载链接，暂时只支持windows系统。</p>
<p> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/05/22/朋友圈九宫格图片/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="苏生不惑">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏生不惑的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/2019/05/22/朋友圈九宫格图片/" itemprop="url">朋友圈九宫格图片</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-05-22T11:48:45+08:00">
                2019-05-22
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                  <span class="post-meta-divider">|</span>
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  386 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  2 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>朋友圈和微博的图片都是九宫格，如何让一张图切为9图呢，在github上找到 <a href="https://github.com/yumendy/nine_picture" target="_blank" rel="noopener">https://github.com/yumendy/nine_picture</a> 这个项目。</p>
<h2 id="安装pil"><a href="#安装pil" class="headerlink" title="安装pil"></a>安装pil</h2><p>pip install pillow</p>
<h2 id="源码"><a href="#源码" class="headerlink" title="源码"></a>源码</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> PIL <span class="keyword">import</span> Image</span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">class NinePictures(object):</span><br><span class="line">    def __init__(self, file_path, mode):</span><br><span class="line">        self.image = Image.open(file_path)</span><br><span class="line">        self.width, self.height = self.image.size</span><br><span class="line">        <span class="keyword">if</span> mode == <span class="string">'C'</span>:</span><br><span class="line">            self.length = self.width <span class="keyword">if</span> self.width &lt; self.height <span class="keyword">else</span> self.height</span><br><span class="line">            self.cut_image()</span><br><span class="line">        elif mode == <span class="string">'F'</span>:</span><br><span class="line">            self.length = self.width <span class="keyword">if</span> self.width &gt; self.height <span class="keyword">else</span> self.height</span><br><span class="line">            self.fill_image()</span><br><span class="line"></span><br><span class="line">    def cut_image(self):</span><br><span class="line">        <span class="keyword">if</span> self.width &lt; self.height:</span><br><span class="line">            self.cut_height()</span><br><span class="line">        elif self.width &gt; self.height:</span><br><span class="line">            self.cut_width()</span><br><span class="line"></span><br><span class="line">    def cut_height(self):</span><br><span class="line">        box = (<span class="number">0</span>, (self.height - self.width) / <span class="number">2</span>, self.width, (self.height + self.width) / <span class="number">2</span>)</span><br><span class="line">        self.image = self.image.crop(box)</span><br><span class="line"></span><br><span class="line">    def cut_width(self):</span><br><span class="line">        box = ((self.width - self.height) / <span class="number">2</span>, <span class="number">0</span>, (self.height + self.width) / <span class="number">2</span>, self.height)</span><br><span class="line">        self.image = self.image.crop(box)</span><br><span class="line"></span><br><span class="line">    def fill_image(self):</span><br><span class="line">        new_image = Image.new(self.image.mode, (self.length, self.length), color=<span class="string">'white'</span>)</span><br><span class="line">        <span class="keyword">if</span> self.width &gt; self.height:</span><br><span class="line">            self.fill_height(new_image)</span><br><span class="line">        elif self.width &lt; self.height:</span><br><span class="line">            self.fill_width(new_image)</span><br><span class="line"></span><br><span class="line">    def fill_height(self, new_image):</span><br><span class="line">        new_image.paste(self.image, (<span class="number">0</span>, (self.length - self.height) / <span class="number">2</span>))</span><br><span class="line">        self.image = new_image</span><br><span class="line"></span><br><span class="line">    def fill_width(self, new_image):</span><br><span class="line">        new_image.paste(self.image, ((self.length - self.width) / <span class="number">2</span>, <span class="number">0</span>))</span><br><span class="line">        self.image = new_image</span><br><span class="line"></span><br><span class="line">    def process(self):</span><br><span class="line">        length = self.length / <span class="number">3</span></span><br><span class="line">        left_list = [<span class="number">0</span>, length, length * <span class="number">2</span>] * <span class="number">3</span></span><br><span class="line">        upper_list = [<span class="number">0</span>] * <span class="number">3</span> + [length] * <span class="number">3</span> + [length * <span class="number">2</span>] * <span class="number">3</span></span><br><span class="line">        right_list = [length, length * <span class="number">2</span>, length * <span class="number">3</span>] * <span class="number">3</span></span><br><span class="line">        lower_list = [length] * <span class="number">3</span> + [length * <span class="number">2</span>] * <span class="number">3</span> + [length * <span class="number">3</span>] * <span class="number">3</span></span><br><span class="line"></span><br><span class="line">        box_list = zip(left_list, upper_list, right_list, lower_list)</span><br><span class="line"></span><br><span class="line">        image_list = [self.image.crop(box) <span class="keyword">for</span> box <span class="keyword">in</span> box_list]</span><br><span class="line"></span><br><span class="line">        <span class="keyword">return</span> image_list</span><br><span class="line"></span><br><span class="line">    def save_image(self):</span><br><span class="line">        image_list = self.process()</span><br><span class="line"></span><br><span class="line">        order_number = <span class="number">1</span></span><br><span class="line">        <span class="keyword">for</span> image <span class="keyword">in</span> image_list:</span><br><span class="line">            image.save(str(order_number) + <span class="string">'.png'</span>, <span class="string">'PNG'</span>)</span><br><span class="line">            order_number += <span class="number">1</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    image_mode = sys.argv[<span class="number">1</span>]</span><br><span class="line">    image_path = sys.argv[<span class="number">2</span>]</span><br><span class="line">    app = NinePictures(image_path, image_mode)</span><br><span class="line">    app.save_image()</span><br></pre></td></tr></table></figure>
<h2 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h2><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">python main.py C image_path # 居中裁剪</span><br><span class="line"></span><br><span class="line">python main.py F image_path # 白色填充</span><br></pre></td></tr></table></figure>
<p>以我的公众号图片为例 python main.py C qr.jpg</p>
<h2 id="效果"><a href="#效果" class="headerlink" title="效果"></a>效果</h2><p>原图<br> <img src="https://upload-images.jianshu.io/upload_images/17817191-6e0079f95d4c0338.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="扫描二维码关注"><br>九宫格，来自<a href="https://weibo.com/2717930601/HtQyXhfTk?ref=home" target="_blank" rel="noopener">微博 </a><br><img src="https://upload-images.jianshu.io/upload_images/17817191-1c95013b8ee416b5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="微博"></p>
<p>现在可以去朋友圈试试了。</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/33/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/33/">33</a><span class="page-number current">34</span><a class="page-number" href="/page/35/">35</a><span class="space">&hellip;</span><a class="page-number" href="/page/39/">39</a><a class="extend next" rel="next" href="/page/35/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">苏生不惑</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">382</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">37</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/sushengbuhuo" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mysusheng@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://plus.google.com/mysusheng" target="_blank" title="Google">
                      
                        <i class="fa fa-fw fa-google"></i>Google</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-block">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                Links
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="http://v2ex.com/" title="v2ex" target="_blank">v2ex</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.fanhaobai.com/" title="fanhaobai" target="_blank">fanhaobai</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://yuanxuxu.com/archives/" title="yuanxuxu" target="_blank">yuanxuxu</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.snail-c.cn/article" title="snail-c" target="_blank">snail-c</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://showcj.com/archives" title="showcj" target="_blank">showcj</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://vultr.aicnm.com/%E6%9C%80%E6%96%B0Vultr%E6%B3%A8%E5%86%8C%E5%8F%8AVPS%E8%B4%AD%E4%B9%B0%E5%9B%BE%E6%96%87%E6%95%99%E7%A8%8B/" title="vultr" target="_blank">vultr</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.lucissfer.com/" title="lucissfer" target="_blank">lucissfer</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.csdn.net/fdipzone/article/details/79352685" title="傲雪星枫" target="_blank">傲雪星枫</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.yoby123.cn/index.php/category/default/" title="小白的分享" target="_blank">小白的分享</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.cnblogs.com/52fhy/p/5819995.html" title="PHP攻城狮" target="_blank">PHP攻城狮</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.jiaojie.site/" title="php" target="_blank">php</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://sphard.com/archives/" title="sphard" target="_blank">sphard</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://yuanxuxu.com/archives/" title="LNMP技术栈笔记" target="_blank">LNMP技术栈笔记</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.coding10.com/" title="学习 Laravel" target="_blank">学习 Laravel</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://shuwoom.com/?page_id=929" title="区块链学习指南" target="_blank">区块链学习指南</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://greenlightt.github.io/archives/" title="greenlightt" target="_blank">greenlightt</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.0php.net/archives/" title="0php" target="_blank">0php</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.fordba.com/category/mysql" title="mysql" target="_blank">mysql</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.itcodemonkey.com/" title="程序员" target="_blank">程序员</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.yanshuo.me/r/v2ex" title="言说" target="_blank">言说</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.timiguo.com/archive.html" title="提米果的博客" target="_blank">提米果的博客</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://phpartisan.cn/news/112.html" title="phpartisan" target="_blank">phpartisan</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.cnblogs.com/52fhy/" title="飞鸿影" target="_blank">飞鸿影</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.54php.cn/" title="54php" target="_blank">54php</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.lazyman.vip/" title="营销" target="_blank">营销</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.njphper.com/archives/" title="做人呢最重要的就是开心" target="_blank">做人呢最重要的就是开心</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.h57.pw/" title="php 初心者" target="_blank">php 初心者</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

<div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">苏生不惑</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>



<div>
<span id="showDays"></span>

</div>

<span id="busuanzi_container_site_pv">
   总访问量:<span id="busuanzi_value_site_pv"></span>次
</span>



  <span class="post-meta-divider">|</span>



<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共773.8k字</span>
</div>
<script>
var birthDay = new Date("11/20/2018");
var now = new Date();
var duration = now.getTime() - birthDay.getTime();
var total= Math.floor(duration / (1000 * 60 * 60 * 24));
document.getElementById("showDays").innerHTML = "本站已运行 "+total+" 天";
</script>

        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  











<script type="text/javascript">
    (function() {
        // 匿名函数，防止污染全局变量
        var utterances = document.createElement('script');
        utterances.type = 'text/javascript';
        utterances.async = true;
        utterances.setAttribute('issue-term','0')
        utterances.setAttribute('theme','')
        utterances.setAttribute('repo','sushengbuhuo/laravel_ioc_demo')
        utterances.crossorigin = 'anonymous';
        utterances.src = 'https://utteranc.es/client.js';
        // content 是要插入评论的地方
        document.getElementById('gitment-container').appendChild(utterances);
    })();
</script>


  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

  
<script>
  ((window.gitter = {}).chat = {}).options = {
    //room替换成自己的聊天室名称即可，room的名称规则是：username/roomname
    room: 'sushengbuhuo-chat/mychat'
  };
</script>
<script src="https://sidecar.gitter.im/dist/sidecar.v1.js" async defer></script>

</body>
</html>
